/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tarea1graficas;

import javafx.scene.CustomNode;
import javafx.scene.image.Image;
import javafx.scene.Node;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.Cursor;


public class CloseButton extends CustomNode {
    var image:Image;
    var images:Image[];
    public var onClicked:function():Void;

    init {

        images = [
            Image { url: "{__DIR__}flecha-derecha.png" },
            Image { url: "{__DIR__}flecha-derechauno.png" },
        ]
        ;
        image = images[0];

    }

    override public function create():Node {
        return ImageView {
                 x: 800.0, y: 600.0
                fitWidth:100
                fitHeight:100
                cursor:Cursor.HAND
            image: bind image
            onMouseEntered:function(e:MouseEvent) {
                image = images[1]
            }
            onMouseExited:function(e:MouseEvent) {
                image = images[0]
            }
            onMousePressed:function(e:MouseEvent) {
                image = images[1]
            }
            onMouseReleased:function(e:MouseEvent) {
                image = images[0];
                if(onClicked != null) {
                    onClicked();

                }
            }
        }
    }

}
